<?php

namespace app\admin\model;

use Exception;

/**
 * @property int $id
 * @property int $company_id
 * @property int $status
 * @property int $order_status
 */
class CompanyOrder extends Base
{
    /**
     * 监听模型更改状态事件
     * @param CompanyOrder $model
     * @return void
     * @throws Exception
     */
    public static function onBeforeUpdate(CompanyOrder $model): void
    {
        if($model->getOrigin('order_status')!= 1)exception('订单状态错误');//只有订单状态为1时,后台才有权限进行审核,一旦审核,不能进行二次更改
        //记录日志
        (new CompanyOrderLog())->add($model->id, $model->order_status, request()->param('remark', ''));
    }
}